package redistool

import (
	"fmt"
	"github.com/garyburd/redigo/redis"
	"helloworld/config"
)

// 主服务器，存放了微信凭证
var RedisPool *redis.Pool

// 新服务器，什么都没存~
var RedisPool2 *redis.Pool

func init() {
	// RedisPool = newPool("10.10.30.20:6379", "", 0)
	RedisPool = newPool("localhost:6379", "", 0)
	conn := RedisPool.Get()
	defer conn.Close()
	rs, e := redis.String(conn.Do("ping"))
	if e != nil {
		panic(e.Error())
	}
	fmt.Println(rs)

	switch config.SrvCtx.Mode {
	case "pro":
		RedisPool2 = newPool("10.10.30.17:6379", "echo123#qp", 0)
	default:
		RedisPool2 = newPool("localhost:6379", "", 0)
	}
	conn2 := RedisPool2.Get()
	defer conn2.Close()
	rs, e = redis.String(conn2.Do("ping"))
	if e != nil {
		panic(e.Error())
	}
	fmt.Println(rs)
}
